<!--
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
  <xsl:apply-templates /> 
</xsl:template>

<xsl:template match="component">
	<span stlye="position:absolute; height:100px; top:0px">
		<xsl:attribute name="id">
			<xsl:value-of select="@id"/>
		</xsl:attribute>
		<xsl:variable name="comp_id">
			<xsl:text>ln_</xsl:text><xsl:value-of select="@id"/>
		</xsl:variable>
		<a style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px">
			<xsl:attribute name="id">
				<xsl:value-of select="$comp_id"/>
			</xsl:attribute>
			<xsl:attribute name="title">
				<xsl:for-each select="property/property">
					<xsl:if test="@key='Title'">
						<xsl:value-of select="."/><xsl:text></xsl:text>
					</xsl:if>
				</xsl:for-each>			
			</xsl:attribute>
			<!--used to identify the property to set-->
			<xsl:attribute name="databind">
				<xsl:value-of select="$comp_id"/>
			</xsl:attribute>
			<xsl:attribute name="databind2">
				<xsl:text>ln_</xsl:text><xsl:value-of select="@id"/><xsl:text>_link</xsl:text>
			</xsl:attribute>
			
			<xsl:attribute name="href">
				<xsl:text>#</xsl:text>
			</xsl:attribute>
			
			<xsl:attribute name="onclick">
				<xsl:text>if(SEMF._goto) {SEMF._goto(</xsl:text>
				
				<!--retrive the link name -->
				<xsl:text>document.getElementById('</xsl:text>
					<xsl:text>ln_</xsl:text>
					<xsl:value-of select="//@id"/>
					<xsl:text>_link</xsl:text>
				<xsl:text>').value , [ </xsl:text>
				
				<xsl:for-each select=
					"//property[@key='Links']/property[contains(@key,'Link-Param')]">
					<xsl:variable name="index">
						<xsl:value-of select="string(position())"/>
					</xsl:variable>
					<xsl:variable name="link_param_key">
						<xsl:value-of select="concat('Link-Param',$index)"></xsl:value-of>
					</xsl:variable>
					<xsl:variable name="key">
						<xsl:value-of select="substring-before(.,'=')"/>
					</xsl:variable>
					
					<!--get the key -->
					<xsl:text>'</xsl:text>
					<xsl:value-of select="$key"/>
					<xsl:text>',</xsl:text>
					
					<xsl:text>SEMF.getSiblingWithAttri(this, 'databind','</xsl:text>
						<xsl:text>ln_</xsl:text>
						<xsl:value-of select="//@id"/>
						<xsl:text>_param_</xsl:text>
						<xsl:value-of select="$link_param_key"/>
					<xsl:text>').value, </xsl:text>
					
				</xsl:for-each>	
					
				<xsl:text>null]); }</xsl:text>				
			</xsl:attribute>
			
			<xsl:for-each select="property/property">
				<xsl:if test="@key='Text'">
					<xsl:value-of select="."/><xsl:text></xsl:text>
				</xsl:if>
			</xsl:for-each>
		</a>
			
		<input type="hidden">
			<xsl:attribute name="id">
				<xsl:text>ln_</xsl:text>
				<xsl:value-of select="//@id"/>
				<xsl:text>_link</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="databind">
				<xsl:text>ln_</xsl:text>
				<xsl:value-of select="//@id"/>
				<xsl:text>_link</xsl:text>
			</xsl:attribute>
		</input>
		
		<xsl:for-each select=
			"//property[@key='Links']/property[contains(@key,'Link-Param')]">
			<xsl:variable name="index">
				<xsl:value-of select="string(position())"/>
			</xsl:variable>
			<xsl:variable name="link_param_key">
				<xsl:value-of select="concat('Link-Param',$index)"></xsl:value-of>
			</xsl:variable>
			
			<input type="hidden">
				<xsl:attribute name="id">
					<xsl:text>ln_</xsl:text>
					<xsl:value-of select="//@id"/>
					<xsl:text>_param_</xsl:text>
					<xsl:value-of select="$link_param_key"/>
				</xsl:attribute>
				<xsl:attribute name="databind">
					<xsl:text>ln_</xsl:text>
					<xsl:value-of select="//@id"/>
					<xsl:text>_param_</xsl:text>
					<xsl:value-of select="$link_param_key"/>
				</xsl:attribute>
				<xsl:attribute name="key">
					<xsl:value-of select="substring-before(.,'=')"/>
				</xsl:attribute>
			</input>
		</xsl:for-each>
		
	</span>
</xsl:template>
</xsl:stylesheet>